package com.yxkj.sms;

import android.content.Context;
import android.os.Environment;

import java.io.File;
public class CommonConfig {

    private static CommonConfig me;

    public static CommonConfig instance() {
        if (me != null) {
            return me;
        } else {
            return me = new CommonConfig(MyApplication.Instance());
        }
    }

    public CommonConfig() {
        me = this;
    }

    public CommonConfig(Context context) {
        me = this;
        init(context);
    }

    public static String PATH = "";
//    public static String CACHE = "";
    public static String CRASH = "";

    private void init(Context context) {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
                && Environment.getExternalStorageDirectory().canWrite()) {
            // 有访问SDCARD
            File sdCardDir = Environment.getExternalStorageDirectory();
            PATH = sdCardDir.getPath() + "/17phone/";
        } else {
            PATH = "/17phone/";
        }
        CRASH = PATH + "crash/";
        initPath();
    }

    /**
     * 实例化路径
     */
    private static void initPath() {
        // 创建资源根路径
        File file = new File(PATH);
        if (!file.exists()) {
            file.mkdirs();
        }
        File crash = new File(CRASH);
        if (!crash.exists()) {
            crash.mkdirs();
        }
    }
//    public String getAppPath() {
//        return PATH;
//    }

}
